package com.evan.kdl.test.day01;

import com.evan.kdl.util.CommonUtils;

import java.util.concurrent.CompletableFuture;

/**
 * 需求：使用CompletableFuture开启异步任务读取 news.txt 文件中的新闻稿，并打印输出。
 */
public class RunAsyncDemo3 {
    public static void main(String[] args) {
        CommonUtils.printThreadLog("main start");
        CompletableFuture.runAsync(() -> {
            String news = CommonUtils.readFile("F:\\idea-workspace-personal\\juc-springboot-demo\\src\\main\\resources\\news.txt");
            CommonUtils.printThreadLog(news);
        });
        CommonUtils.printThreadLog("here are not blocked,main continue");
        CommonUtils.sleepSecond(4);
        CommonUtils.printThreadLog("main end");
    }
}